﻿#pragma once
#include <QString>
#include <QMap>
#include <QMenu>
#include <QAction>
#include <QWidget>
#include <QModelIndex>


//结点类型枚举
enum NodeType
{
    NODE_DIR,          // 目录
    NODE_FILE,         // 文件
};

typedef enum ProjectMenu
{
    kSort,                                  // 排序                   ok
    kRemove,                                // 移除                   ok
    kUpMove,                                // 上移                   ok
    kDownMove,                              // 下移                   ok
    kRename,                                // 重命名                  ok
    kMax,

}ProjectMenu;

Q_DECLARE_METATYPE(ProjectMenu)
extern const QMap<ProjectMenu, QString> gMapMenuName;


class ProjectMenuBase: public QObject
{
    Q_OBJECT
public:
    ProjectMenuBase(QModelIndex index, QObject* parent = 0);
    ~ProjectMenuBase();

    virtual NodeType getNodeType() = 0;
    virtual void initAction() = 0;				// 子类实现
    virtual void doMenuAction(ProjectMenu menuType);
    void appendAction(ProjectMenu menu, QString strIconPath, bool bSeparator = false);
    void showMenu();

private:
     QMenu* m_menu;
     QWidget* m_widget;

protected:
     QModelIndex m_index;
};


class ProjectMenuDir : public ProjectMenuBase
{
    Q_OBJECT
public:
    ProjectMenuDir(QModelIndex index, QObject* parent = 0);
    ~ProjectMenuDir();

    virtual NodeType getNodeType() { return NODE_DIR; }
    virtual void initAction();
    virtual void doMenuAction(ProjectMenu menuType);
};

class ProjectMenuFile : public ProjectMenuBase
{
    Q_OBJECT
public:
    ProjectMenuFile(QModelIndex index, QObject* parent = 0);
    ~ProjectMenuFile();

    virtual NodeType getNodeType() { return NODE_FILE; }
    virtual void initAction();
    virtual void doMenuAction(ProjectMenu menuType);
};
